/*******************************************************************************
 * Copyright (c) 2005, 2007 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package us.gaaoc.framework.dao;

import java.util.Date;
import java.util.List;

import us.gaaoc.framework.businessmodel.Filing;
import us.gaaoc.framework.model.CaseRecord;
import us.gaaoc.framework.model.CaseRecordStatus;
import us.gaaoc.framework.model.CaseRecordType;
import us.gaaoc.framework.model.Court;
import us.gaaoc.framework.model.LocalCaseCategory;
import us.gaaoc.framework.model.LocalCaseDivision;
import us.gaaoc.framework.model.LocalCaseFilingType;
import us.gaaoc.framework.model.LocalCaseType;
import us.gaaoc.framework.model.Person;
import us.gaaoc.framework.model.util.CaseRecordsCountPerDay;
import us.gaaoc.framework.model.util.CaseRecordsCountPerMonth;
import us.gaaoc.framework.model.util.DismissedCases;
import us.gaaoc.framework.model.util.DismissedCasesPerMonth;


@SuppressWarnings("unused")
public interface CaseRecordDAO extends GenericDAO<CaseRecord, String>{
		
	public abstract List<CaseRecord> findAllCaseRecordByStatus(int statusCode);	
	public abstract List<CaseRecord> findAllCaseRecordByCaseType(int caseTypeCode);	
	public abstract List<CaseRecord> findAllCaseRecordsByCaseTypeAndStatus(int caseTypeCode, int statusCode1, int statusCode2);
//	public abstract List<CaseRecord> findAllCaseRecordByInstantiationDateTime();
	//public abstract ScrollableResults findAllCaseRecordByInstantiationDateTime();
//	public abstract List<CaseRecord> findNewCaseRecord();
	public abstract List<CaseRecord> findAllCaseRecordByTransmissionError();
	public abstract void updateCaseRecordForClearCase(String filingUuid,boolean isCleart);	
	public abstract List<CaseRecord> findAllClearedCaseRecords(boolean flag);
	
	
	//add by Angela
	public abstract List<Filing> findCaseFilingsByTypeAndStatus(int typeCode, int statusCode);
	// Added for Paging of Imported Filings Queries
	public abstract List<Filing> findCaseFilingsByTypeAndStatusPaged(int typeCode,
			int statusCode, int pageIndex, int limit);  
	public abstract int findNumberOfCaseFilingsByTypeAndStatus(int typeCode,
			int statusCode);
	
	public abstract List<Filing> findCaseFilingsByStatus(int statusCode);
	public abstract List<Filing> findCaseFilingsByType(int typeCode);
	public abstract List<Filing> findClearedCaseFilingsByType(int typeCode);
	//public abstract List<Filing> findErrorFilings();
	public abstract void updateCaseRecordForDeletedFlag(String uuid, boolean isDeleted);
	public abstract List<CaseRecord> findCaseRecordByDocketID(String docketID,String courtUuid);
	public abstract void updateImportedCaseRecord(String uuid, String docketID, CaseRecordStatus status);
	public abstract void updateRejectedCaseRecord(String uuid, String reason, CaseRecordStatus status);
	public abstract void updateCaseRecordCourtTrackingID(String uuid, String docketID); 
	public abstract List<Filing> findClearedCaseFilings();
	public abstract List<Filing> findProgressingFilings();
	public abstract List<Filing> findExistingFilings();
	public abstract List<Filing> findAttorneySideStatusFilings();
	public abstract List<Filing> findCourtSideStatusFilings();
	
	public abstract CaseRecord findCaseRecordByExternalCaseRecordUuidAndExternalCaseTypeCode(String externalCaseRecordUuid, int externalCaseTypeCode);
	public abstract boolean isExternalCaseRecordUuidAndExternalCaseTypeCode(String externalCaseRecordUuid, int externalCaseTypeCode);
	public abstract void insertExternalCaseRecordIntoCaseRecordTable(String caseReocrdUuid, String externalCaseRecordUuid, int externalCaseTypeCode);
	
	public abstract List<Filing> findAllFilingsByTypeForClerk(int typeCode);
	public abstract List<Filing> findAllFilingsByTypeForJudge(int typeCode);
	public abstract List<Filing> findClearedCaseFilingsAgentSide() ;
	public abstract List<Filing> findClearedCaseFilingsClerkSide();
	public abstract void deleteCaseRecord(String caseUuid);
	
	//added by Michael Alexandrou
	//public abstract CaseRecord findCaseRecordByDocketIDAndCourtUuid(String docketID, String courtUuid);
	public abstract List<Filing> findFilingsByExternalCaseRecordNumber(String externalCaseRecordNumber);
	/**
	 * @param typeCode
	 * @param statusCode
	 * @return
	 */
	public abstract int findNumberOfCaseFilingsByTypeAndStatus(int typeCode, int statusCode1, int statusCode2, int statusCode3, int statusCode4);
	/**
	 * @param typeCode
	 * @param statusCode1
	 * @param statusCode2
	 * @param statusCode3
	 * @param statusCode4 
	 * @param pageIndex
	 * @param limit
	 * @return
	 */
	public abstract List<Filing> findCaseFilingsByTypeAndStatus(int typeCode, int statusCode1, int statusCode2, int statusCode3, int statusCode4);
	
	//Added by Frank
	/**
	 * Searches the database for cases that have a participant by a given name.
	 * 
	 * @param firstName the person's first name.
	 * @param middleName the person's middle name.
	 * @param lastName the person's last name.
	 * @param defendantSearch a flag that indicates if the search is limited
	 * to look for only defendants.
	 */
	public abstract List<Filing> findCaseFilingsByPerson(String firstName,
			String middleName, String lastName, boolean defendantSearch);
	
	/**
	 * Searches the database for cases that have a participant by a given name.
	 * This is an outdated implementation of the person search to support
	 * old code.
	 * 
	 * @param firstName the person's first name.
	 * @param middleName the person's middle name.
	 * @param lastName the person's last name.
	 */
	public abstract List<Filing> findCaseFilingsByPerson(String firstName,
			String middleName, String lastName);
	/*
	//add by Angela 6/19/2007
	public abstract List<CaseRecord> findCaseRecordsByTypeandStatus(int typeCode, int statusCode);
	public abstract List<CaseRecord> findCaseRecordsByStatus(int statusCode);
	public abstract List<CaseRecord> findCaseRecordsByType(int typeCode);
	public abstract List<CaseRecord> findClearedCaseRecordsByType(int typeCode);
	public abstract List<CaseRecord> findClearedCaseRecords();
	public abstract List<CaseRecord> findProgressingCaseRecords();
	public abstract List<CaseRecord> findAttorneySideStatusCaseRecords();
	public abstract List<CaseRecord> findCourtSideStatusCaseRecords();
	public abstract List<CaseRecord> findAllCaseRecordsByTypeForClerk(int typeCode);
	public abstract List<CaseRecord> findAllCaseRecordsByTypeForJudge(int typeCode);
	public abstract List<CaseRecord> findClearedCaseRecordsAgentSide() ;
	public abstract List<CaseRecord> findClearedCaseRecordsClerkSide();
	*/
	/**
	 * @param typeCode
	 * @return
	 */
	public abstract int findNumberOfCaseFilingsByType(int typeCode);
	/**
	 * @param caseType
	 * @param startRow
	 * @param pageSize
	 * @return
	 */
	public abstract List<Filing> findCaseFilingsByTypeAndStatus(int caseType, int startRow, int pageSize);
	public abstract List<Filing> findFilingByCaseTrackingId(String caseTrackingId);
	/**
	 * @param caseType
	 * @param status1
	 * @param status2
	 * @param status3
	 * @param status4
	 * @param startRow
	 * @param pageSize
	 * @return
	 */
	public abstract List<Filing> findCaseFilingsByTypeAndStatusPaged(int caseType, int status1, int status2, int status3, int status4, int startRow, int pageSize);
	/**
	 * @param typeCode
	 * @param pageSize 
	 * @param startRow 
	 * @return
	 */
	public abstract List<Filing> findAllFilingsByTypeForClerkPaged(int typeCode, int startRow, int pageSize);
	/**
	 * @param typeCode
	 * @param startRow
	 * @param pageSize
	 * @return
	 */
	public abstract List<Filing> findAllFilingsByTypeForJudgePaged(int typeCode, int startRow, int pageSize);
	/**
	 * @param typeCode
	 * @return
	 */
	public abstract int findNumberOfCaseFilingsByTypeForClerk(int typeCode);
	/**
	 * @param typeCode
	 * @return
	 */
	public abstract int findNumberOfCaseFilingsByTypeForJudge(int typeCode);
	
	public abstract List<Filing> findAllFilingsByTypeForAdmin(int typeCode);
	public abstract int findNumberOfCaseFilingsByTypeForAdmin(int typeCode);
	public abstract List<Filing> findCaseFilingsForPastDays(Date startingDate, Date endingDate, String personLoginUuid);
	/**
	 * @param instanciationDate
	 * @param submittedDate
	 * @param crSt
	 * @param crT
	 * @param c
	 * @param localCaseCategory
	 * @param localCaseDivision
	 * @param localCaseFilingType
	 * @param localCaseType
	 * @return
	 */
	public abstract CaseRecord createCaseRecord(Date instanciationDate,
			Date submittedDate, CaseRecordStatus crSt, CaseRecordType crT,
			Court c, LocalCaseCategory localCaseCategory,
			LocalCaseDivision localCaseDivision,
			LocalCaseFilingType localCaseFilingType, LocalCaseType localCaseType);
	public abstract List<String> findCaseFilingsWithinDateRange(Date startingDate, Date endingDate);
	
	//added by Bhawana
	public abstract int countCaseRecords();
	public abstract int countContemptCases();
	public abstract int countEstablishedCases();
	public abstract List<CaseRecordsCountPerDay> countCasesByDay();
	public abstract List<CaseRecordsCountPerMonth> countCasesByMonth();
	public abstract int countLocalCases();
	public abstract int countFilings();
	public abstract int countProcessedFiling();
	public abstract List<DismissedCases> findDismissedCases() ;
	  public abstract List<DismissedCasesPerMonth>  countDismissedCasesPerMonth();
	/**
	 * change the status of a case record
	 * @param caseReocrd
	 * @param caseRecordStatusCode
	 */
	public abstract void UpdateCaseRecordByStatus(CaseRecord caseReocrd, CaseRecordStatus caseRecordStatusCode);
	
	/**
	 * @param typeCode
	 * @return the filings that are flagged as cleared
	 * One possible use of this method is from the admin module where an authorized administrator
	 * sees all the cleared filings and decides to restore one or more of them
	 */
	public abstract List<Filing> findAllClearedFilings(int typeCode);
	
	/**
	 *  update case filing by the clear filing flag 
	 *  @param caseRecordUuid
	 *  @param clearFilingFlag
	 */
	public abstract void UpdateFilingByClearFilingFlag( int typeCode, String caseRecordUuid, boolean clearFilingFlag);
	
	/**
	 * Method to determine how many rows are possible to be returned by a query 
	 * for case filings that are cleared but not deleted and not archived
	 * 
	 * @param typeCode
	 * @return int Count of number of rows
	 */
	public abstract int findNumberOfClearedFilingsByType(int typeCode);
	
	public abstract int findNumberOfAllCaseRecordsByCaseTypeAndStatus(int typeCode, int statusCode1, int statusCode2);
 

	/**
	 * Gets a list of cases of the type of the passed case record event type
	 * codes from the database and sorts the list by either instantiation date
	 * or last event date in ascending or descending order. Also, will filter
	 * the cases to show only cases that have been worked on by the user.
	 * 
	 * @param caseType the type of case.
	 * @param statusCode1 a case record event type code.
	 * @param statusCode2 a case record event type code.
	 * @param statusCode3 a case record event type code.
	 * @param statusCode4 a case record event type code.
	 * @param desc a flag indicating if the ordered column is descending.
	 * @param orderByEvt a flag indicating if the column is ordered by last event date.
	 * @param personalCasesFilter a flag indicating if the cases shown have all
	 * been worked on by the user.
	 * @return a list of cases.
	 */
	public abstract List<Filing> sortFiling(int caseType, int statusCode1,
			int statusCode2, int statusCode3, int statusCode4, boolean desc,
			boolean orderByEvt, String personalCasesFilter);
	
	/**
	 * Gets a list of cases of the type of the passed case record event type
	 * codes from the database and sorts the list by either instantiation date
	 * or last event date in ascending or descending order. Also, will filter
	 * the cases to show only cases that have been worked on by the user.
	 * 
	 * @param caseType the type of case.
	 * @param statusCode1 a case record event type code.
	 * @param statusCode2 a case record event type code.
	 * @param statusCode3 a case record event type code.
	 * @param statusCode4 a case record event type code.
	 * @param desc a flag indicating if the ordered column is descending.
	 * @param orderByEvt a flag indicating if the column is ordered by last event date.
	 * @param personalCasesFilter a flag indicating if the cases shown have all
	 * been worked on by the user.
	 * @return a list of cases.
	 */
	public abstract List<Filing> sortFiling(int caseType, int statusCode1,
			int statusCode2, int statusCode3, int statusCode4, int statusCode5,
			boolean desc, boolean orderByEvt, String personalCasesFilter);
	
	/**
	 * Gets a list of cases of the type of the passed case record event type
	 * codes from the database and sorts the list by either instantiation date
	 * or last event date in ascending or descending order. Also, will filter
	 * the cases to show only cases that have been worked on by the user.
	 * 
	 * @param caseType the type of case.
	 * @param statusCode1 a case record event type code.
	 * @param statusCode2 a case record event type code.
	 * @param statusCode3 a case record event type code.
	 * @param statusCode4 a case record event type code.
	 * @param statusCode5 a case record event type code.
	 * @param desc a flag indicating if the ordered column is descending.
	 * @param orderByEvt a flag indicating if the column is ordered by last event date.
	 * @param startRow a variable to handle the paging of the list.
	 * @param personalCasesFilter a flag indicating if the cases shown have all
	 * been worked on by the user.
	 * @param pageSize a variable to handle the paging of the list.
	 * @return a list of cases.
	 */
	public abstract List<Filing> sortFilingPaged(int caseType, int statusCode1,
			int statusCode2, int statusCode3, int statusCode4, int statusCode5,
			boolean desc, boolean orderByEvt, int startRow, String personalCasesFilter, 
			int pageSize);
	
	/**
	 * Gets a list of cases of the type of the passed case record event type
	 * codes from the database and sorts the list by either instantiation date
	 * or last event date in ascending or descending order. Also, will filter
	 * the cases to show only cases that have been worked on by the user.
	 * 
	 * @param caseType the type of case.
	 * @param statusCode1 a case record event type code.
	 * @param statusCode2 a case record event type code.
	 * @param statusCode3 a case record event type code.
	 * @param statusCode4 a case record event type code.
	 * @param desc a flag indicating if the ordered column is descending.
	 * @param orderByEvt a flag indicating if the column is ordered by last event date.
	 * @param startRow a variable to handle the paging of the list.
	 * @param personalCasesFilter a flag indicating if the cases shown have all
	 * been worked on by the user.
	 * @param pageSize a variable to handle the paging of the list.
	 * @return a list of cases.
	 */
	public abstract List<Filing> sortFilingPaged(int caseType, int statusCode1,
			int statusCode2, int statusCode3, int statusCode4, boolean desc,
			boolean orderByEvt, int startRow, String personalCasesFilter, 
			int pageSize);

	public abstract String generateDocketId(String prefix);
	public abstract void updateCaseRecord(CaseRecord caseRecord);
	public abstract boolean findCivilActionNumber(String cvNumber);
	
/**
 * These Methods are added for generating the Report Pages	
 * @param statusCode
 * @param courtUuid
 * @param startInstantiationDateTime
 * @param endInstantiationDateTime
 * @return
 */
	public abstract List<Filing> findAllCaseRecordByStatusandCreatedDate(int statusCode,String courtUuid,Date startInstantiationDateTime,Date endInstantiationDateTime);
	public abstract List<Filing> findAllCaseRecordByStatusCodeandLatestEventDateTime(int statusCode,String courtUuid,Date startEventDateTime,Date endEventDateTime);
	public abstract List<Filing> findAllCaseRecordByEventCodeandLatestEventDateTime(int eventCode,String courtUuid,Date startEventDateTime,Date endEventDateTime);
	public abstract List<Filing> findAllCaseRecordByEventCodeandEventDateTime(int eventCode,String courtUuid,Date startEventDateTime,Date endEventDateTime);

	
 }